package com.five.second_shop.service;

import com.five.second_shop.entity.Order;
import com.five.second_shop.mapper.OrderMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class OrderService {
    @Autowired
    public OrderMapper orderMapper;
    /**创建订单*/
    public Integer insertOrder(Order order){
        return orderMapper.insertOrder(order);
    }
    /**删除订单*/
    public Integer delectOrder(String id){
        return orderMapper.delectOrder(id);
    }
    /**修改订单*/
    public Integer updateOrder(Order order){
        return orderMapper.updateOrder(order);
    }
    /**查看所有订单*/
    public Order queryOrderById(String id){
        return orderMapper.queryOrderById(id);
    }
    /**查询订单总数*/
    public Integer queryOrderCount(String userid){
        return orderMapper.queryOrderCount(userid);
    }
    /**分页展示订单信息*/
    public List<Order>queryAllOrder(@Param("page")Integer page,@Param("cunt")Integer cunt,Order order){
        return orderMapper.queryAllOrder(page, cunt,order);
    }
    public List<Order>queryByUserid(String userid){
        return  orderMapper.queryByUserid(userid);
    }

    /**
     * 查询订单 附带 商品信息
     * @param order
     * @return
     */
    public List<Order> LookOrder(Order order){return  orderMapper.LookOrder(order);}
}
